/**
 * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springblade.modules.bank.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.common.tool.MyStringUtil;
import org.springblade.modules.bank.entity.TmCustomerCallRecord;
import org.springblade.modules.bank.vo.CallRecordWjVO;
import org.springblade.modules.bank.vo.TmCustomerCallRecordVO;
import org.springblade.modules.bank.mapper.TmCustomerCallRecordMapper;
import org.springblade.modules.bank.service.ITmCustomerCallRecordService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.io.File;
import java.util.List;
import java.util.Map;

/**
 * 客户呼叫记录 服务实现类
 *
 * @author Blade
 * @since 2022-07-08
 */
@Service
public class TmCustomerCallRecordServiceImpl extends ServiceImpl<TmCustomerCallRecordMapper, TmCustomerCallRecord> implements ITmCustomerCallRecordService {

	@Value("${recordFilePath}")
	private String recordFilePath;

	@Override
	public IPage<TmCustomerCallRecordVO> selectTmCustomerCallRecordPage(IPage<TmCustomerCallRecordVO> page, TmCustomerCallRecordVO tmCustomerCallRecord) {
		return page.setRecords(baseMapper.selectTmCustomerCallRecordPage(page, tmCustomerCallRecord));
	}

	@Override
	public List<CallRecordWjVO> callRecordWjList(TmCustomerCallRecordVO tmCustomerCallRecord){
		return baseMapper.callRecordWjList(tmCustomerCallRecord);
	}

	public void deleteRecordFile(List<TmCustomerCallRecord> removeList){
		removeList.forEach(item->{
			if(MyStringUtil.isNotEmpty(item.getFilePath())){
				File file = new File(recordFilePath+"/"+item.getFilePath());
				file.delete();
			}
		});
	}

	@Override
	public List<Map> queryBySql(String sql){
		return baseMapper.queryBySql(sql);
	}

	@Override
	public int deleteBySql(String sql) {
		return baseMapper.deleteBySql(sql);
	}

	@Override
	public int updateBySql(String sql){
		return baseMapper.updateBySql(sql);
	}
}
